import axios from 'axios';
import {message} from 'antd';
axios.interceptors.request.use((config) => {
    if (config.url.indexOf("@") != -1) {
        config.url = config.url.replace("@", SystemConfig.configs.axiosUrl);
    }
    config.headers['X-Requested-With'] = 'XMLHttpRequest';
    config.headers['If-Modified-Since'] = '0';
    return config
})
const errMsg = "系统错误!请重试,或联系管理员.";
axios.interceptors.response.use((response) => {
    // if(response.status==302){
    //     //302说明这里未登录
    //     window.location.href=systemConfig.financialPath;
    // }
    if (response.data == undefined || (response.data && response.data.status == "FAILURE")) {
        message.error(errMsg);
        return undefined;
    }
    return response.data;
}, (err) => {
    console.log(err);
    message.error(errMsg);
    return Promise.reject(err);
})